//
//  MainTabBar.swift
//  0110-weibo
//
//  Created by 鲍志刚 on 16/1/10.
//  Copyright © 2016年 zhongye. All rights reserved.
//

import UIKit

class MainTabBar: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

//        print(tabBar.classForCoder)
        
        let mainTabBar = ZGTabbar()
        setValue(mainTabBar, forKey: "tabBar")
        mainTabBar.plusBtn.addTarget(self, action: "plusBtnDidClick", forControlEvents: .TouchUpInside)
        
//        print(tabBar.classsForCoder)
        
        addChildViewControllers()
        
    }
    
    func plusBtnDidClick (){
    
    print(__FUNCTION__)
    
    }
    
    
    
    func addChildViewControllers(){
    
        addChildViewController(HomeTableViewController(), imageName: "tabbar_home", title: "首页")
        
        addChildViewController(MessageTableViewController(), imageName: "tabbar_message_center", title: "信息")
        
        addChildViewController(DiscoverTableViewController(), imageName: "tabbar_discover", title: "发现")
        
        addChildViewController(ProfileTableViewController(), imageName: "tabbar_profile", title: "我")

    }
    

    func addChildViewController(vc:UIViewController, imageName:String, title:String) {
        
        vc.tabBarItem.image = UIImage(named: imageName)
        
        self.tabBar.tintColor = UIColor.orangeColor()
        
        vc.title = title
//        vc.tabBarItem.title = title
//        vc.navigationItem.title = title
        
        let nav = UINavigationController(rootViewController: vc)
        
        addChildViewController(nav)
        
    }
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
